package com.yunze.apiCommon.upstreamAPI.YiDongEC.Inquire;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunze.apiCommon.upstreamAPI.YiDongEC.YD_EC_Api;
import com.yunze.apiCommon.utils.HttpUtil;
import com.yunze.apiCommon.utils.UrlUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 查询类接口
 */
public class Query_YD extends YD_EC_Api {


    public static void main(String[] args) {
        Map<String, Object> init_map = new HashMap<String, Object>();
        init_map.put("cd_username", "C5010531Ai1202063298");//
        init_map.put("cd_pwd", "dOg,5sADA9Xs");//
        init_map.put("cd_key", "1");//
        Query_YD quer = new Query_YD(init_map,"YiDong_EC");
        quer.appId = init_map.get("cd_username").toString();
        quer.password = init_map.get("cd_pwd").toString();
        quer.cd_code = "YiDong_EC";
        quer.server_Ip = "https://api.iot.10086.cn/v5/ec";


        String method = quer.server_Ip + "/query/sim-voice-usage";

        Map<String, Object> params = new HashMap<String, Object>();

        params.put("token",quer.token );
        params.put("iccid", "898608001521C0000755");
        params.put("transid", quer.appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));


        //https://api.iot.10086.cn/v5/ec/query/sim-voice-usage?transid=xxx&token=xxx&iccid=xxx -以

        String pinUrl= "https://api.iot.10086.cn/v5/ec/query/sim-voice-usage?transid="+quer.appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())+"&token="+quer.token+"&iccid=898608001521C0000755";
        System.out.println(quer.token);
        String reqUrl = UrlUtil.getUrl(method, params);
        String res = HttpUtil.get(pinUrl);
        System.out.println("res = " + res);
        JSONObject json = JSON.parseObject(res);

        System.out.println(json);
//        Object status = json.get("status");
//        if (status != null && status.toString().equals("0")) {
//            Map<String, String> map = ((List<Map<String, String>>) json.get("result")).get(0);
//            quer.token = map.get("token");
//        }
//        //  System.out.println(quer.queryGroupInfo("50","1"));
//
//
//        System.out.println(quer.queryGroupMember("50","1","1111000012822157"));
//
//        //  System.out.println(quer.queryCardActiveTime("1440646081133"));



    }
    public String queryWhiteVoice(Map<String,Object> pMap ) {
        String iccid = pMap.get("iccid").toString();
        String functionNm =   "/query/sim-voice-usage";//成功 但是 无信息
        // String functionNm =   "/query/sim-voice-margin";//查询不到信息
        String pinUrl =  server_Ip+functionNm+"?transid="+appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())+"&token="+token+"&iccid="+iccid;
        String res = HttpUtil.get(pinUrl);
        Map<String, Object> resMap = JSON.parseObject(res);
        String status = resMap.get("status").toString();
        if (status.equals("0")){
           List<Map<String,Object>> useList = (List<Map<String,Object>>) resMap.get("result");
            String voiceAmount = useList.get(0).get("voiceAmount").toString();
            return voiceAmount;
        }
        return "错误";
    }
    public Map<String,Object> setWhite(Map<String,Object> PMap) {
        HashMap<String, Object> rMap = new HashMap<>();
        String iccid = PMap.get("iccid").toString();
        String groupId = PMap.get("groupId").toString();
        String whiteNumber = PMap.get("addNumber").toString();
        //String whiteNumber ="18615133198";
        String operType = "1";
        try {
            String functionNm = "/config/member-voice-whitelist";//配置 白名单
            String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid + "&groupId=" + groupId + "&operType=1" + "&whiteNumber=" + whiteNumber;
            String res = HttpUtil.get(pinUrl);
            Map<String, Object> resBody = (Map<String, Object>) JSON.parseObject(res);
            return resBody;
        }catch (Exception e){
            return  null;
        }

    }
    public Map<String,Object> delWhite(Map<String,Object> PMap) {
        HashMap<String, Object> rMap = new HashMap<>();
        String iccid = PMap.get("iccid").toString();
        String groupId = PMap.get("groupId").toString();
        String whiteNumber = PMap.get("delNumber").toString();
        //String whiteNumber ="18615133198";
        String operType = "1";
        try {
            String functionNm = "/config/member-voice-whitelist";//配置 白名单
            String pinUrl = server_Ip + functionNm + "?transid=" + appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()) + "&token=" + token + "&iccid=" + iccid + "&groupId=" + groupId + "&operType=4" + "&whiteNumber=" + whiteNumber;
            String res = HttpUtil.get(pinUrl);
            Map<String, Object> resBody = (Map<String, Object>) JSON.parseObject(res);
            return resBody;
        }catch (Exception e){
            return  null;
        }

    }
    public List<Map<String,Object>> getWhite(Map<String,Object> map) {// 查询成员组
        String iccid = map.get("iccid").toString();
        String groupId = map.get("groupId").toString();
        String functionNm ="/query/member-voice-whitelist"; //https://api.iot.10086.cn/v5/ec/query/member-voice-whitelist
        String pinUrl =  server_Ip+functionNm+"?transid="+appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())+"&token="+token+"&iccid="+iccid+"&groupId="+groupId;
        String res = HttpUtil.get(pinUrl);
        Map<String, Object> resMap = JSON.parseObject(res);
        String status = resMap.get("status").toString();
        if (status.equals("0")){//成功
            List<Map<String,Object>> bodyList =(List<Map<String,Object>>)resMap.get("result");
            Map<String, Object> whiteMap = bodyList.get(0);
            List<Map<String,Object>> whiteList =(List<Map<String,Object>>)whiteMap.get("memVoiceWhiteList");
            return whiteList;//白名单列表
        }
        return null;
    }
    public String getGroup(String card_no) {//查询 卡号所在 的 语音通信分组
        //String functionNm =   "/query/sim-voice-usage";//成功 但是 无信息https://api.iot.10086.cn/v5/ec/query/group-by-member
        String functionNm =   "/query/group-by-member";//查询不到信息
        String pinUrl =  server_Ip+functionNm+"?transid="+appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date())+"&token="+token+"&iccid="+card_no;
        String res = HttpUtil.get(pinUrl);
        Map<String,Object> resMap= (Map<String,Object>)JSONObject.parseObject(res);
        String status = resMap.get("status").toString();
        if (status.equals("0")){//成功
            List result = (List)resMap.get("result");
            Map<String,Object> groupList = (Map<String,Object>)result.get(0);
            List<Map<String,Object>> all= (List<Map<String,Object>>)groupList.get("groupList");
            for (int i = 0; i < all.size(); i++) {
                Map<String, Object> map = all.get(i);
                String offeringName = map.get("offeringName").toString();
                if (offeringName.indexOf("语音通信")!=-1){//存在
                    return map.get("groupId").toString();
                }
            }

        }

        return "错误!!";
    }
    public Query_YD() {
        super();
    }

    public Query_YD(Map<String, Object> init_map,String cd_code) {
        super(init_map,cd_code);
    }






    /**
     * 单卡本月套餐内流量使用量实时查询
     * @param card_no
     * @return
     */
    public String queryGprsMarginBySim(String card_no) {
        String functionNm =   "/query/sim-data-margin";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String url = server_Ip + functionNm;
        String Str = send(url,json);
        return repeat(Str,json,url);
    }



    /**
     * 单卡接口查询卡状态
     * @param card_no
     * @return
     */
    public String queryCardStatus(String card_no)  {
        String functionNm =   "/query/sim-status";

        JSONObject json = new JSONObject();
        String cardStatus = null;
        String lastChangeDate = null;
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        json.put("msisdn", card_no);
        String Str = send(url,json);
        return repeat(Str,json,url);
    }

    /**
     * 月流量查询接口
     * @param card_no
     * @return
     */
    public String selectFlow(String card_no) {
        String functionNm =   "/query/sim-data-usage";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String url = server_Ip + functionNm;
        String Str = send(url,json);
        //System.out.println(Str);
        return repeat(Str,json,url);
    }

    /**
     * 查询指定月份的已用流量。6个月内的
     *
     * @param card_no
     * @param queryDate
     * @return
     */
    public String designatedMonth(String card_no, String queryDate) {
        String functionNm =  "/query/sim-data-usage-monthly/batch";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdns", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        json.put("queryDate", queryDate);
        String url = server_Ip + functionNm;
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * 单卡卡状态操作
     * @param card_no
     * @param flag
     * @return
     */
    /*public String changeCardStatus(String card_no, String flag) {
        String functionNm =  "/change/sim-status";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        json.put("operType", flag);
        String Str = send(url,json);
        return repeat(Str,json,url);
    }*/

    /**
     * 查询单卡的机卡分离状态
     * @param card_no
     * @return
     */
    public String queryCardBindStatus(String card_no) {
        String functionNm =  "/query/card-bind-status";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        String cardStatus = null;
        String sepTime = null;
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        json.put("testType", 0);
        String Str = send(url,json);
        return repeat(Str,json,url);
    }

    /**
     * 解除单卡的机卡分离
     * @param card_no
     * @return
     */
   /* public String upCardBindStatus(String card_no) {
        String functionNm =  "/operate/card-bind-by-bill";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        json.put("operType", 2);
        String Str = send(url,json);
        return repeat(Str,json,url);
    }*/

    /**
     * 单卡查询激活以及开卡时间
     * @param card_no
     * @return
     */
    public String queryCardActiveTime(String card_no) {
        String functionNm =  "/query/sim-basic-info";
        JSONObject retult = new JSONObject();
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        String Str = send(url,json);
        return repeat(Str,json,url);
    }

    /**
     * @param @param  card_no
     * @param @return 参数
     * @return JSONObject    返回类型
     * @throws
     * @Description:单卡查询apn状态
     * @author
     * @date 2020年5月25日
     */
    public  Map<String, Object> queryApnStatus(String card_no) {
        String functionNm =  "/query/sim-communication-function-status";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        //String Str = HttpUtil.post(url, json.toJSONString());
        String Str = send(url,json);
        return JSONObject.parseObject(repeat(Str,json,url));
    }

    /**
     *  流量池信息查询
     * @return
     */
    public static String queryFlowPool(){
        String functionNm =  "/query/group-data-margin";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
        }
        json.put("groupId", appId);
        String Str = HttpUtil.post(url, json.toJSONString());

        return Str;

    }


    /**
     * 单卡在线信息实时查询
     * @param card_no
     * @return
     */
    public String sim_session(String card_no) {
        String functionNm =  "/query/sim-session";
        JSONObject json = new JSONObject();
        String cardStatus = null;
        String lastChangeDate = null;
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }

        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * 单卡实时使用终端 IMEI 查询
     * @param card_no
     * @return
     */
    public String queryCardImei(String card_no) {
        String functionNm =  "/query/sim-imei";
        JSONObject json = new JSONObject();
        String cardStatus = null;
        String lastChangeDate = null;
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }



    /**
     * 单卡停机原因查询
     * @param card_no
     * @return
     */
    public String simStopReason(String card_no) {
        String functionNm =  "/query/sim-stop-reason";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }




    /**
     * 单卡开关机状态实时查询
     * @param card_no
     * @return
     */
    public String onOffStatus(String card_no) {
        String functionNm =  "/query/on-off-status";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }

    /**
     * 单卡已开通APN信息查询
     * @param card_no
     * @return
     */
    public String apnInfo(String card_no) {
        String functionNm =  "/query/apn-info";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * 物联卡机卡分离状态查询
     * @param card_no
     * @param testType 分离检测方式：
     * 0：话单侧检测
     * 1：网络侧检测
     * @return
     */
    public String cardBindStatus(String card_no,String testType) {
        String functionNm =  "/query/card-bind-status";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
            json.put("testType", testType);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("testType", testType);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }



    /**
     * 单卡状态变更历史查询
     * @param card_no
     * @return
     */
    public String simChangeHistory(String card_no) {
        String functionNm =  "/query/sim-change-history";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }








    /**
     * 单卡本月套餐内流量使用量实时查
     * @param card_no
     * @return
     */
    public String simDataMargin(String card_no) {
        String functionNm =  "/query/sim-data-margin";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }



    /**
     * 资费订购实时查询
     * @param card_no
     * @return
     */
    public String queryOffering(String card_no) {
        String functionNm =  "/query/ordered-offerings";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("msisdn", card_no);
            json.put("queryType", "3");
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("queryType", "3");
            Map<String,Object> requestParams = new HashMap<>();
            requestParams.put("msisdn",card_no);
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * CMIOT_API23E06-集团群组信息查询
     * @param pageSize 每页查询的数目，不超过50
     * @param startNum 开始页，从1开始
     * @return
     */
    public String queryGroupInfo(String pageSize,String startNum) {
        String functionNm =  "/query/group-info";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("pageSize", pageSize);
            json.put("startNum", startNum);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("pageSize", pageSize);
            json.put("startNum", startNum);
            Map<String,Object> requestParams = new HashMap<>();
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }

    /**
     * CMIOT_API23E01-群组所属成员查询
     * @param pageSize 每页查询的数目，不超过50
     * @param startNum 开始页，从1开始
     * @param groupId 群组ID
     * @return
     */
    public String queryGroupMember(String pageSize,String startNum,String groupId) {
        String functionNm =  "/query/group-member";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("groupId", groupId);
            json.put("pageSize", pageSize);
            json.put("startNum", startNum);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("groupId", groupId);
            json.put("pageSize", pageSize);
            json.put("startNum", startNum);
            Map<String,Object> requestParams = new HashMap<>();
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * 物联卡终端控制下行模板短信记录批量
     * @param msisdns
     * @param startDate
     * @param endDate
     * @return
     */
    public String querySimMtSms(String msisdns,String startDate,String endDate) {
        String functionNm =  "/query/sim-mt-sms/batch";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("startDate", startDate);
            json.put("msisdns", msisdns);
            json.put("endDate", endDate);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("startDate", startDate);
            json.put("msisdns", msisdns);
            json.put("endDate", endDate);
            Map<String,Object> requestParams = new HashMap<>();
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    /**
     * 9.2.3CMIOT_API25C03-物联卡终端控制上行短信记录批量
     * @param msisdns
     * @param startDate
     * @param endDate
     * @return
     */
    public String querySimMoSms(String msisdns,String startDate,String endDate) {
        String functionNm =  "/query/sim-mo-sms/batch";
        JSONObject json = new JSONObject();
        String url = server_Ip + functionNm;
        if(!cd_code.equals("YiDong_EC_TengYu")){
            json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
            json.put("token", token);
            json.put("startDate", startDate);
            json.put("msisdns", msisdns);
            json.put("endDate", endDate);
        }else{
            json.put("interface", functionNm);
            json.put("appid", appId);
            json.put("startDate", startDate);
            json.put("msisdns", msisdns);
            json.put("endDate", endDate);
            Map<String,Object> requestParams = new HashMap<>();
            json.put("requestParams", requestParams);
        }
        String Str = send(url,json);
        return repeat(Str,json,url);
    }


    public String FunctionApnCardStop(String msisdn, String operType) {
        String functionNm = "/change/sim-status";
        JSONObject json = new JSONObject();
        json.put("transid", appId + new SimpleDateFormat("YYYYMMDDHHMMSS").format(new Date()));
        json.put("token", token);
        json.put("msisdn", msisdn);
        json.put("operType", operType);
        String url = server_Ip + functionNm;
        String Str = send(url, json);
        return repeat(Str, json, url);
    }
}
